<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS的变量_typeof</title>

    <script>
    // 定义变量
    /* var a = 3;
    alert(a);

    a = "abc";
    alert(a); */

    // 定义 number 类型
    var num = 1;
    var num2 = 1.1;
    var num3 = NaN;

    // 输出到页面上
    document.write(num + " --- " + typeof(num) + "<br>");
    document.write(num2+ " --- " + typeof(num2) +"<br>");
    document.write(num3+ " --- " + typeof(num3) +"<br><br>");

    // 定义 string 类型
    var str = "abc";
    var str2 = 'a';
    document.write(str + " --- " + typeof(str) + "<br>");
    document.write(str2 + " --- " + typeof(str2) + "<br><br>");

    // 定义 boolean 类型
    var flag = true;
    document.write(flag + " --- " + typeof(flag) + "<br><br>");

    // 定义 null 类型
    var obj = null;
    var obj2 = undefined;
    var obj3;
    document.write(obj + " --- " + typeof(obj) + "<br>");
    document.write(obj2 + " --- " + typeof(obj2) + "<br>");
    document.write(obj3 + " --- " + typeof(obj3) + "<br><br>");

    </script>

</head>
<body>

</body>
</html>